package Util;
import java.io.Serializable;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;




public class connect implements Serializable {
	  	
	  private static Connection cnConexao_SqlServer;
	  
	 
	  public ResultSet rs_mysql(Connection conn, String StrSql, String State) throws SQLException{
	   ResultSet rsDados_Server = null;		 
	   
	   try{
	     PreparedStatement ptConsulta_SqlServer = conn.prepareStatement(StrSql, ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
    
		   System.out.println(StrSql);
		 
	     if (State.equals("Select")){
		   rsDados_Server = ptConsulta_SqlServer.executeQuery();
		 }else if (State.equals("Update")){
		   ptConsulta_SqlServer.executeUpdate();
		 }
	   }catch (Exception e){
	   }
	   
	   return rsDados_Server;
     }
	 
			 
	 public static Connection getMYSQLConnection(){
		 Connection conn = null;
		 try { 
			 
			  String url = "jdbc:mysql://db4free.net:3306/bingo";
		      String login = "wilramone";
		      String senha = "wcvwcv";

		         Class.forName("com.mysql.jdbc.Driver").newInstance();
		         conn = DriverManager.getConnection(url, login, senha);		    
		      
		  }
		  catch (SQLException e) {
			 System.out.println(e);   
		  } catch (Exception e) {
			  System.out.println(e);
		  }
			    
			    return conn;
	  }
}
